<!--
 * @Descripttion: 
 * @version: 
 * @Author: ruxiang.wang
 * @Date: 2021-06-04 17:06:37
 * @LastEditors: ruxiang.wang
 * @LastEditTime: 2021-07-02 20:28:25
-->
<template>
  <div class="app-container">
    <!-- 新建单元、编辑单元弹窗 -->
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="方案名称" prop="tabName">
        <el-input v-model="ruleForm.tabName"></el-input>
      </el-form-item>
      <el-form-item label="部署方案" prop="deploymentPlan">
        <el-select style="width:100%;" v-model="ruleForm.deploymentPlan" :multiple="true" placeholder="请选择部署方案">
          <el-option
            v-for="item in deploymentPlanOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="功能配置" prop="model">
        <el-button size="medium" type="primary" @click="innerVisible=true">新增</el-button>
        <el-button size="medium" type="primary" @click="jumpOther">新增（路由跳转）</el-button>
      </el-form-item>
      <!-- 功能配置数据表格 -->
      <el-table
        v-if="tableDataFun.length>0"
        :data="tableDataFun"
        border
        style="width: 100%;margin-top:20px;">
        <el-table-column
          prop="nameInner"
          label="功能"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="nameInner"
          label="功能主题"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="nameInner"
          label="封面图">
          <template slot-scope="scope">
            <el-image
              v-if="scope.row.imageUrl !==''"
              style="width: 120px; height: 80px"
              :src="scope.row.imageUrl"
              fit="fill">
            </el-image>
            <span
              v-else
              style="color:green;"
            >暂无封面图</span>
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          width="180">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="delFun(scope.row)">编辑</el-button>
            <el-button type="text" size="small" @click="delFun(scope.row)">上移</el-button>
            <el-button type="text" size="small" @click="delFun(scope.row)">下移</el-button>
            <el-button type="text" size="small" @click="delFun(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 功能配置（新增/编辑）第二层弹窗 -->
      <el-dialog
        width="45%"
        title="功能配置（新增/编辑）"
        :visible.sync="innerVisible"
        :close-on-click-modal="false"
        append-to-body>
        <el-form :model="ruleForm1" :rules="rules1" ref="ruleForm" label-width="100px" class="demo-ruleForm">
          <el-form-item label="功能名称" prop="name">
            <el-input v-model="ruleForm1.name"></el-input>
          </el-form-item>
          <el-form-item label="封面图片" prop="region">
            
          </el-form-item>
          <el-form-item label="主题" prop="title">
            
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="innerVisible=false">取 消</el-button>
          <el-button type="primary" @click="innerVisible=false">确 定</el-button>
        </span>
      </el-dialog>
    </el-form>
  </div>
</template>

<script>

export default {

  data() {
    return {
      // 部署方案下拉框数据
      deploymentPlanOptions:[{
        value: 'chinese',
        label: '部署方案1'
      }, {
        value: 'usa',
        label: '部署方案2'
      }],
      // 新建单元、编辑单元弹窗
      dialogTitle:'',
      dialogVisible: true,
      ruleForm: {
        tabName: '',
        deploymentPlan: '',
        model:'',
      },
      rules: {
        tabName: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        deploymentPlan: [
          { required: true, message: '请选择部署方案', trigger: 'change' }
        ],
        model: [
          { required: true, message: '请选择部署方案', trigger: 'change' }
        ],
      },
      tableDataFun:[{
        nameInner: 'TCL',
        codeInner: '20160502',
        imageUrl:'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
      }],
      // 功能配置（新增/编辑）第二层弹窗
      innerVisible:false,
      ruleForm1: {
        name: '',
        region: '',
        model: ''
      },
      rules1: {
        name: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        region: [
          { required: true, message: '请选择部署国家', trigger: 'change' }
        ],
        model: [
          { required: true, message: '请选择生效机型', trigger: 'change' }
        ],
      },
    }
  },
  watch: {
    
  },

  methods: {
    // 跳转其他路由界面
    jumpOther(row) {
      this.$router.push({ path: '/instructions/index', params: { userId: 'ruxiang.wang' }}) //带参跳转
    },
    
  }
}
</script>

